#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define ll long long
#define stoorz_and_QuantAsk using
#define AK namespace
#define IOI_and_Jayun_is_stupid std

stoorz_and_QuantAsk AK IOI_and_Jayun_is_stupid;

const int N = 8010, M = 2e5 + 10;

inline ll Read()
{
	ll x = 0, f = 1;
	char c = getchar();
	while (c != '-' && (c < '0' || c > '9')) c = getchar();
	if (c == '-') f = -f, c = getchar();
	while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + c - '0', c = getchar();
	return x * f;
}

int n, q, m;
int a[N], b[N];

int main()
{
	freopen("sort.in", "r", stdin);
	freopen("sort.out", "w", stdout);
	m = n = Read(), q = Read();
	for (int i = 1; i <= n; i++) a[i] = Read();
	for (int i = 1; i <= q; i++)
	{
		int opt = Read(), qa = Read();
		if (opt == 1) a[qa] = Read();
		else
		{
			memcpy(b, a, sizeof a);
			sort (b + 1, b + 1 + n);
			int ans = 0;
			for (int i = 1; i < qa; i++)
				if (a[i] == a[qa]) ans++;
			ans += lower_bound(b + 1, b + 1 + n, a[qa]) - b;
			printf ("%d\n", ans);
		}
	}
	return 0;
}

